import threading

from django.apps import AppConfig



class MyThread(threading.Thread):
    """
    封装的thread线程函数，为了获取子线程的返回值
    """

    def __init__(self, func, args=()):
        super(MyThread, self).__init__()
        self.func = func
        self.args = args

    def run(self):
        self.result = self.func(*self.args)

    def get_result(self):
        try:
            return self.result  # 如果子线程不使用join方法，此处可能会报没有self.result的错误
        except Exception:
            return None
